package com.wilmer.stemCourse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.wilmer.common.core.domain.entity.SysDept;
import com.wilmer.stemCourseCon.domain.StemCourseCon;
import com.wilmer.stemCourseCon.service.StemCourseConService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wilmer.common.annotation.Log;
import com.wilmer.common.core.controller.BaseController;
import com.wilmer.common.core.domain.AjaxResult;
import com.wilmer.common.enums.BusinessType;
import com.wilmer.stemCourse.domain.YwStemCourse;
import com.wilmer.stemCourse.service.IYwStemCourseService;
import com.wilmer.common.utils.poi.ExcelUtil;
import com.wilmer.common.core.page.TableDataInfo;

/**
 * STEM课程Controller
 *
 * @author zl
 * @date 2024-04-15
 */
@RestController
@RequestMapping("/stemCourse/stemCourse")
public class YwStemCourseController extends BaseController
{
    @Autowired
    private IYwStemCourseService ywStemCourseService;
    @Autowired
    private StemCourseConService stemCourseConService;


    /**
     * 查询STEM课程列表
     */
    @PreAuthorize("@ss.hasPermi('stemCourse:stemCourse:list')")
    @GetMapping("/list")
    public TableDataInfo list(YwStemCourse ywStemCourse)
    {
        startPage();
        List<YwStemCourse> list = ywStemCourseService.selectYwStemCourseList(ywStemCourse);
        return getDataTable(list);
    }

    /**
     * 导出STEM课程列表
     */
    @PreAuthorize("@ss.hasPermi('stemCourse:stemCourse:export')")
    @Log(title = "STEM课程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YwStemCourse ywStemCourse)
    {
        List<YwStemCourse> list = ywStemCourseService.selectYwStemCourseList(ywStemCourse);
        ExcelUtil<YwStemCourse> util = new ExcelUtil<YwStemCourse>(YwStemCourse.class);
        util.exportExcel(response, list, "STEM课程数据");
    }

    /**
     * 获取STEM课程详细信息
     */
    @PreAuthorize("@ss.hasPermi('stemCourse:stemCourse:query')")
    @GetMapping(value = "/{courseId}")
    public AjaxResult getInfo(@PathVariable("courseId") Long courseId)
    {
        return success(ywStemCourseService.selectYwStemCourseByCourseId(courseId));
    }

    /**
     * 新增STEM课程
     */
    @PreAuthorize("@ss.hasPermi('stemCourse:stemCourse:add')")
    @Log(title = "STEM课程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YwStemCourse ywStemCourse)
    {
        return toAjax(ywStemCourseService.insertYwStemCourse(ywStemCourse));
    }

    /**
     * 修改STEM课程
     */
    @PreAuthorize("@ss.hasPermi('stemCourse:stemCourse:edit')")
    @Log(title = "STEM课程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YwStemCourse ywStemCourse)
    {
        return toAjax(ywStemCourseService.updateYwStemCourse(ywStemCourse));
    }

    /**
     * 删除STEM课程
     */
    @PreAuthorize("@ss.hasPermi('stemCourse:stemCourse:remove')")
    @Log(title = "STEM课程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{courseIds}")
    public AjaxResult remove(@PathVariable Long[] courseIds)
    {
        return toAjax(ywStemCourseService.deleteYwStemCourseByCourseIds(courseIds));
    }
    /**
     * 获取课程结构树列表
     */
    @PreAuthorize("@ss.hasPermi('stemCourse:stemCourse:list')")
    @GetMapping("/stemCourseConTree")
    public AjaxResult stemCourseConTree(StemCourseCon stemCourseCon)
    {
        return success(stemCourseConService.selectStemCourseConTreeList(stemCourseCon));
    }
}
